#include "GLSceneMapDrawers.h"

#include <iostream>
#include <vector>
#include <cmath>
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif

#include "PathCoordinate.h"

namespace catan
{

/*private*/ GLSceneMapDrawers::GLSceneMapDrawers()
{
}

/*static*/ void GLSceneMapDrawers::drawBackground(float multiplier, GLuint backgroundTexture)
{
	GLfloat oldColor[4];
	glGetFloatv(GL_CURRENT_COLOR, oldColor);
	GLint oldTexture;
	glGetIntegerv(GL_TEXTURE_BINDING_2D, &oldTexture);
	    glColor3f(0.5f, 0.5f, 0.5f);
	    glBindTexture(GL_TEXTURE_2D, backgroundTexture);
	    glBegin(GL_QUADS);
	    	glTexCoord2f(1.0f, 0.0f);
		    glVertex3f(0.5f*multiplier, -0.5f*multiplier, 0.0f);
		    
	    	glTexCoord2f(0.0f, 0.0f);
		    glVertex3f(-0.5f*multiplier, -0.5f*multiplier, 0.0f);
		    
	    	glTexCoord2f(0.0f, 1.0f);
		    glVertex3f(-0.5f*multiplier, 0.5f*multiplier, 0.0f);
		    
	    	glTexCoord2f(1.0f, 1.0f);
		    glVertex3f(0.5f*multiplier, 0.5f*multiplier, 0.0f);
	    glEnd();
    glBindTexture(GL_TEXTURE_2D, oldTexture);
	glColor3f(oldColor[0], oldColor[1], oldColor[2]);
}

/*static*/ void GLSceneMapDrawers::drawHexagons(float multiplier, GLTextures &glTextures, GameMap &gameMap, std::vector<Player*> thePlayerVector, GameState &gameState, MouseMotionArtifacts mouseMotionArtifacts)
{
    for (int j=0; j<7; ++j)
    {
    	for (int i=0; i<7; ++i)
    	{
    		int iPlusJ = i+j;
    		if (iPlusJ < 3 || iPlusJ > 9) continue;
	    	GLuint texture;
	    	CoordinateX coordinateX(static_cast<CoordinateX::Enum_CoordinateX>(i));
	    	CoordinateY coordinateY(static_cast<CoordinateY::Enum_CoordinateY>(j));
	    	Cell cell = gameMap.getCell(CellCoordinate(coordinateX, coordinateY));
			CellType cellType = cell.getType();
			if (cellType == pastureType) texture = glTextures.getSheepTexture();
			else if (cellType == forestType) texture = glTextures.getWoodsTexture();
			else if (cellType == fieldsType) texture = glTextures.getWheatTexture();
			else if (cellType == hillsType) texture = glTextures.getBrickTexture();
			else if (cellType == mountainsType) texture = glTextures.getOreTexture();
			else if (cellType == desertType) texture = glTextures.getDesertTexture();
			else if (cellType == generalHarborType) texture = glTextures.getGeneralHarborTexture();
			else if (cellType == woodHarborType) texture = glTextures.getWoodHarborTexture();
			else if (cellType == sheepHarborType) texture = glTextures.getSheepHarborTexture();
			else if (cellType == wheatHarborType) texture = glTextures.getWheatHarborTexture();
			else if (cellType == brickHarborType) texture = glTextures.getBrickHarborTexture();
			else if (cellType == oreHarborType) texture = glTextures.getOreHarborTexture();
			else texture = glTextures.getSeaTexture();
			CellNumber cellNumber = cell.getNumber();
    		GLSceneMapDrawers::drawHexagon(texture, glTextures.getTileTexture(cellNumber.getEnum()), i, j, multiplier*0.16, thePlayerVector, gameState, mouseMotionArtifacts);
    	}
    }	
}

void GLSceneMapDrawers::drawSettlement(float playerRed, float playerGreen, float playerBlue, float centerX, float centerY, float multiplier)
{
	glBegin(GL_POLYGON);
		glColor3f(playerRed, playerGreen, playerBlue);
		glVertex3f(centerX+multiplier*0.1f, centerY-multiplier*0.1f, 0.15f*multiplier);
		glVertex3f(centerX, centerY-multiplier*0.1f, 0.2f*multiplier);
		glVertex3f(centerX, centerY+multiplier*0.1f, 0.2f*multiplier);
		glVertex3f(centerX+multiplier*0.1f, centerY+multiplier*0.1f, (0.15f)*multiplier);
	glEnd();
	glBegin(GL_POLYGON);
		glColor3f(playerRed*0.7f, playerGreen*0.7f, playerBlue*0.7f);
		glVertex3f(centerX, centerY-multiplier*0.1f, 0.2f*multiplier);
		glVertex3f(centerX-multiplier*0.1f, centerY-multiplier*0.1f, 0.15f*multiplier);
		glVertex3f(centerX-multiplier*0.1f, centerY+multiplier*0.1f, 0.15f*multiplier);
		glVertex3f(centerX, centerY+multiplier*0.1f, 0.2f*multiplier);
	glEnd();
	glBegin(GL_POLYGON);
		glColor3f(playerRed*0.85f, playerGreen*0.85f, playerBlue*0.85f);
		glVertex3f(centerX+multiplier*0.1f, centerY+multiplier*0.1f, 0.15f*multiplier);
		glVertex3f(centerX, centerY+multiplier*0.1f, 0.2f*multiplier);
		glVertex3f(centerX-multiplier*0.1f, centerY+multiplier*0.1f, 0.15f*multiplier);
		glVertex3f(centerX-multiplier*0.1f, centerY+multiplier*0.1f, 0.0f);
		glVertex3f(centerX+multiplier*0.1f, centerY+multiplier*0.1f, 0.0f);
	glEnd();
	glBegin(GL_POLYGON);
		glColor3f(playerRed*0.55f, playerGreen*0.55f, playerBlue*0.55f);
		glVertex3f(centerX-multiplier*0.1f, centerY-multiplier*0.1f, 0.0f);
		glVertex3f(centerX-multiplier*0.1f, centerY-multiplier*0.1f, 0.15f*multiplier);
		glVertex3f(centerX-multiplier*0.1f, centerY+multiplier*0.1f, 0.15f*multiplier);
		glVertex3f(centerX-multiplier*0.1f, centerY+multiplier*0.1f, 0.0f);
	glEnd();
	glBegin(GL_POLYGON);
		glColor3f(playerRed*0.6f, playerGreen*0.6f, playerBlue*0.6f);
		glVertex3f(centerX+multiplier*0.1f, centerY-multiplier*0.1f, 0.15f*multiplier);
		glVertex3f(centerX, centerY-multiplier*0.1f, 0.2f*multiplier);
		glVertex3f(centerX-multiplier*0.1f, centerY-multiplier*0.1f, 0.15f*multiplier);
		glVertex3f(centerX-multiplier*0.1f, centerY-multiplier*0.1f, 0.0f);
		glVertex3f(centerX+multiplier*0.1f, centerY-multiplier*0.1f, 0.0f);
	glEnd();
	glBegin(GL_POLYGON);
		glColor3f(playerRed*0.8f, playerGreen*0.8f, playerBlue*0.8f);
		glVertex3f(centerX+multiplier*0.1f, centerY-multiplier*0.1f, 0.0f);
		glVertex3f(centerX+multiplier*0.1f, centerY-multiplier*0.1f, 0.15f*multiplier);
		glVertex3f(centerX+multiplier*0.1f, centerY+multiplier*0.1f, 0.15f*multiplier);
		glVertex3f(centerX+multiplier*0.1f, centerY+multiplier*0.1f, 0.0f);
	glEnd();
}

void GLSceneMapDrawers::drawCity(float playerRed, float playerGreen, float playerBlue, float centerX, float centerY, float multiplier)
{
	static const float hexagonX[6] = {0.5f, 0.25f, -0.25f, -0.5f, -0.25f, 0.25f};
	static const float hexagonY[6] = {0.0f, -0.4330127018922f, -0.4330127018922f, 0.0f, 0.4330127018922f, 0.4330127018922f};
	glBegin(GL_POLYGON);
		glColor3f(playerRed*0.8f, playerGreen*0.8f, playerBlue*0.8f);
		for (int i=0; i<6; ++i)
		{
			glVertex3f(centerX+multiplier*0.25f*hexagonX[i], centerY+multiplier*0.25f*hexagonY[i], 0.2f*multiplier);
		}
	glEnd();
	glBegin(GL_POLYGON);
		glColor3f(playerRed*0.8f, playerGreen*0.8f, playerBlue*0.8f);
		for (int i=0; i<6; ++i)
		{
			glVertex3f(centerX+multiplier*0.15f*hexagonX[i], centerY+multiplier*0.15f*hexagonY[i], 0.35f*multiplier);
		}
	glEnd();
	glBegin(GL_QUADS);
		for (int i=0; i<6; ++i)
		{
			glColor3f(playerRed*((abs(3-i)+2)*0.2f), playerGreen*((abs(3-i)+2)*0.2f), playerBlue*((abs(3-i)+2)*0.2f));
			glVertex3f(centerX+multiplier*0.15f*hexagonX[i], centerY+multiplier*0.15f*hexagonY[i], 0.35f*multiplier);
			glVertex3f(centerX+multiplier*0.15f*hexagonX[i], centerY+multiplier*0.15f*hexagonY[i], 0.2f*multiplier);
			glVertex3f(centerX+multiplier*0.15f*hexagonX[(i+1)%6], centerY+multiplier*0.15f*hexagonY[(i+1)%6], 0.2f*multiplier);
			glVertex3f(centerX+multiplier*0.15f*hexagonX[(i+1)%6], centerY+multiplier*0.15f*hexagonY[(i+1)%6], 0.35f*multiplier);
		}
	glEnd();
	glBegin(GL_QUADS);
		for (int i=0; i<6; ++i)
		{
			glColor3f(playerRed*((abs(3-i)+2)*0.2f), playerGreen*((abs(3-i)+2)*0.2f), playerBlue*((abs(3-i)+2)*0.2f));
			glVertex3f(centerX+multiplier*0.25f*hexagonX[i], centerY+multiplier*0.25f*hexagonY[i], 0.2f*multiplier);
			glVertex3f(centerX+multiplier*0.25f*hexagonX[i], centerY+multiplier*0.25f*hexagonY[i], 0.0f);
			glVertex3f(centerX+multiplier*0.25f*hexagonX[(i+1)%6], centerY+multiplier*0.25f*hexagonY[(i+1)%6], 0.0f);
			glVertex3f(centerX+multiplier*0.25f*hexagonX[(i+1)%6], centerY+multiplier*0.25f*hexagonY[(i+1)%6], 0.2f*multiplier);
		}
	glEnd();
}

void GLSceneMapDrawers::drawRoad(float playerRed, float playerGreen, float playerBlue, float centerX, float centerY, int pathPosition, float multiplier)
{
	static const float hexagonX[6] = {0.5f, 0.25f, -0.25f, -0.5f, -0.25f, 0.25f};
	static const float hexagonY[6] = {0.0f, -0.4330127018922f, -0.4330127018922f, 0.0f, 0.4330127018922f, 0.4330127018922f};
	float centerZ = 0.02f * multiplier;
	float growthVectorX = (hexagonX[(pathPosition+1)%6] - hexagonX[pathPosition]) * 0.5f * multiplier;
	float growthVectorY = (hexagonY[(pathPosition+1)%6] - hexagonY[pathPosition]) * 0.5f * multiplier;
	float normalVectorX = (hexagonY[(pathPosition+1)%6] - hexagonY[pathPosition]) * 0.086602540378443837f * multiplier;
	float normalVectorY = -(hexagonX[(pathPosition+1)%6] - hexagonX[pathPosition]) * 0.086602540378443837f * multiplier;
	float roadHeight = 0.02f * multiplier;
	float cornerXs[8];
	float cornerYs[8];
	float cornerZs[8];
	int l=0;
	for (int i=-1; i<=1; i+=2) for (int j=-1; j<=1; j+=2) for (int k=-1; k<=1; k+=2)
	{
		cornerXs[l] = centerX + growthVectorX*i + normalVectorX*j; 
		cornerYs[l] = centerY + growthVectorY*i + normalVectorY*j;
		cornerZs[l] = centerZ + roadHeight*k;
		l++;
	}
	int arrayOfRectangleNodes[6][4] = {
			{0, 1, 3, 2},
			{0, 1, 5, 4},
			{0, 2, 6, 4},
			{1, 3, 7, 5},
			{2, 3, 7, 6},
			{4, 5, 7, 6}
	};
	glBegin(GL_QUADS);
		for (int i=0; i<6; ++i)
		{
			for (int j=0; j<4; ++j)
			{
				int nodeIndex = arrayOfRectangleNodes[i][j];
				glVertex3f(cornerXs[nodeIndex], cornerYs[nodeIndex], cornerZs[nodeIndex]);
			}
		}
	glEnd();
}

/*static*/ void GLSceneMapDrawers::drawHexagon(GLuint texture, GLuint numberTexture, int x, int y, float multiplier, std::vector<Player*> thePlayerVector, GameState &gameState, MouseMotionArtifacts mouseMotionArtifacts)
{
	static const float hexagonX[6] = {0.5f, 0.25f, -0.25f, -0.5f, -0.25f, 0.25f};
	static const float hexagonY[6] = {0.0f, -0.4330127018922f, -0.4330127018922f, 0.0f, 0.4330127018922f, 0.4330127018922f};
	float xShift = 0.75f*(x-3);
	float yShift = (0.4330127018922193f*(x-3) + 0.8660254037844386f*(y-3));
	if (texture != 0)
	{
		glBindTexture(GL_TEXTURE_2D, texture);
	}
    glBegin(GL_POLYGON);
    	for (int k=0; k<6; ++k)
    	{
			glTexCoord2f(hexagonX[k]+0.5f, hexagonY[k]+0.5f);
	        glVertex3f((hexagonX[k]*0.9f+xShift)*multiplier, (hexagonY[k]*0.9f+yShift)*multiplier, (0.04f)*multiplier);
    	}
    glEnd();
    if (texture != 0)
    {
    	glBindTexture(GL_TEXTURE_2D, 0);
    }
    glBegin(GL_QUADS);
	    for (int k=0; k<6; ++k)
	    {
	        glColor3f(0.92549019607843142f*((abs(3-k)+2)*0.2f), 0.81568627450980391f*((abs(3-k)+2)*0.2f), 0.51764705882352946f*((abs(3-k)+2)*0.2f));
		    glVertex3f((hexagonX[k]*0.9f+xShift)*multiplier, (hexagonY[k]*0.9f+yShift)*multiplier, (0.04f)*multiplier);
		    glVertex3f((hexagonX[(k+1)%6]*0.9f+xShift)*multiplier, (hexagonY[(k+1)%6]*0.9f+yShift)*multiplier, (0.04f)*multiplier);
		    glVertex3f((hexagonX[(k+1)%6]*1.0f+xShift)*multiplier, (hexagonY[(k+1)%6]*0.95f+yShift)*multiplier, 0.0f);
		    glVertex3f((hexagonX[k]*1.0f+xShift)*multiplier, (hexagonY[k]*0.95f+yShift)*multiplier, 0.0f);
	    }
    glEnd();
	// thePlayerVector
	for (std::vector<Player *>::iterator playerIterator = thePlayerVector.begin(); playerIterator != thePlayerVector.end(); ++playerIterator)
	{
		Player * playerRef = * playerIterator;	// the current player
		std::vector<SiteCoordinate> playerSettlements = playerRef->getSettlements();
		for(std::vector<SiteCoordinate>::iterator settlementIterator = playerSettlements.begin(); settlementIterator != playerSettlements.end(); ++settlementIterator){
			if (SiteCoordinate::canInit(CoordinateX(static_cast<CoordinateX::Enum_CoordinateX>(x)),CoordinateY(static_cast<CoordinateY::Enum_CoordinateY>(y)),settlementIterator->getHorizontalCardinal()))
			{
				SiteCoordinate currentSiteCoordinate = SiteCoordinate(CoordinateX(static_cast<CoordinateX::Enum_CoordinateX>(x)),CoordinateY(static_cast<CoordinateY::Enum_CoordinateY>(y)),settlementIterator->getHorizontalCardinal());
				if(*settlementIterator == currentSiteCoordinate)
				{
    				int HOUSE_RIGHT = 0;
    				int HOUSE_LEFT = 3;
					int settlementPosition = (settlementIterator->getHorizontalCardinal()==catan::horizontalCR? HOUSE_RIGHT: HOUSE_LEFT);
					float playerRed = playerRef->getRed();
    				float playerGreen = playerRef->getGreen();
    				float playerBlue = playerRef->getBlue();
    				glColor3f(playerRed, playerGreen, playerBlue);
    				float centerX = (hexagonX[settlementPosition]+xShift)*multiplier;
    				float centerY = (hexagonY[settlementPosition]+yShift)*multiplier;
    				CoordinateX coordinateX(static_cast<CoordinateX::Enum_CoordinateX>(x));
    				CoordinateY coordinateY(static_cast<CoordinateY::Enum_CoordinateY>(y));
    				bool canDrawSettlement = true;
    				if (mouseMotionArtifacts.hasMouseMotionSettlement() && mouseMotionArtifacts.isMouseMotionSettlementUpgraded())
	    			{
    					if (mouseMotionArtifacts.getMouseMotionSettlement() == currentSiteCoordinate)
    					{
    						canDrawSettlement = false;
    					}
	    			}
    				if (canDrawSettlement)
    				{
    					drawSettlement(playerRed, playerGreen, playerBlue, centerX, centerY, multiplier);
    				}
				}
			}
		}
	}
	// thePlayerVector
	for (std::vector<Player *>::iterator playerIterator = thePlayerVector.begin(); playerIterator != thePlayerVector.end(); ++playerIterator)
	{
		Player * playerRef = * playerIterator;	// the current player
		std::vector<SiteCoordinate> playerCities = playerRef->getCities();
		for(std::vector<SiteCoordinate>::iterator cityIterator = playerCities.begin(); cityIterator != playerCities.end(); ++cityIterator){
			if (SiteCoordinate::canInit(CoordinateX(static_cast<CoordinateX::Enum_CoordinateX>(x)),CoordinateY(static_cast<CoordinateY::Enum_CoordinateY>(y)),cityIterator->getHorizontalCardinal()))
			{
				SiteCoordinate currentSiteCoordinate = SiteCoordinate(CoordinateX(static_cast<CoordinateX::Enum_CoordinateX>(x)),CoordinateY(static_cast<CoordinateY::Enum_CoordinateY>(y)),cityIterator->getHorizontalCardinal());
				if(*cityIterator == currentSiteCoordinate){
	
					int HOUSE_RIGHT = 0;
					int HOUSE_LEFT = 3;
	
					int sitePosition = (cityIterator->getHorizontalCardinal()==catan::horizontalCR? HOUSE_RIGHT: HOUSE_LEFT);
					float playerRed = playerRef->getRed();
					float playerGreen = playerRef->getGreen();
					float playerBlue = playerRef->getBlue();
	
					glColor3f(playerRed, playerGreen, playerBlue);
					float centerX = (hexagonX[sitePosition]+xShift)*multiplier;
					float centerY = (hexagonY[sitePosition]+yShift)*multiplier;
					drawCity(playerRed, playerGreen, playerBlue, centerX, centerY, multiplier);
				}
			}
		}
	}
	// thePlayerVector
	for (std::vector<Player *>::iterator playerIterator = thePlayerVector.begin(); playerIterator != thePlayerVector.end(); ++playerIterator){
		Player * playerRef = * playerIterator;	// the current player
		std::vector<PathCoordinate> playerRoads = playerRef->getRoads();
		for(std::vector<PathCoordinate>::iterator roadIterator = playerRoads.begin(); roadIterator != playerRoads.end(); ++roadIterator){
			if (PathCoordinate::canInit(CoordinateX(static_cast<CoordinateX::Enum_CoordinateX>(x)),CoordinateY(static_cast<CoordinateY::Enum_CoordinateY>(y)),roadIterator->getVerticalCardinal()))
			{
				PathCoordinate currentPathCoordinate = PathCoordinate(CoordinateX(static_cast<CoordinateX::Enum_CoordinateX>(x)),CoordinateY(static_cast<CoordinateY::Enum_CoordinateY>(y)),roadIterator->getVerticalCardinal());
				if(*roadIterator == currentPathCoordinate){
					int PATH_TR = 0;
					int PATH_TL = 2;
					int PATH_BC = 4;
					int pathPosition;
					if(roadIterator->getVerticalCardinal()==catan::verticalTR)
						pathPosition = PATH_TR;
					else if(roadIterator->getVerticalCardinal()==catan::verticalTL)
						pathPosition = PATH_TL;
					else if(roadIterator->getVerticalCardinal()==catan::verticalBC)
						pathPosition = PATH_BC;
	
					float playerRed = playerRef->getRed();
					float playerGreen = playerRef->getGreen();
					float playerBlue = playerRef->getBlue();
					glColor3f(playerRed, playerGreen, playerBlue);
					float centerX = ((hexagonX[pathPosition]+hexagonX[(pathPosition+1)%6])/2+xShift)*multiplier;
					float centerY = ((hexagonY[pathPosition]+hexagonY[(pathPosition+1)%6])/2+yShift)*multiplier;
					drawRoad(playerRed, playerGreen, playerBlue, centerX, centerY, pathPosition, multiplier);
				}
			}
		}
	}
	if (mouseMotionArtifacts.hasMouseMotionSettlement())
	{
		CoordinateX coordinateX(static_cast<CoordinateX::Enum_CoordinateX>(x));
		CoordinateY coordinateY(static_cast<CoordinateY::Enum_CoordinateY>(y));
		HorizontalCardinal horizontalCardinal = mouseMotionArtifacts.getMouseMotionSettlement().getHorizontalCardinal();
		if (SiteCoordinate::canInit(coordinateX, coordinateY, horizontalCardinal))
		{
			SiteCoordinate currentSiteCoordinate(coordinateX, coordinateY, horizontalCardinal);
			if (currentSiteCoordinate == mouseMotionArtifacts.getMouseMotionSettlement())
			{
				int HOUSE_RIGHT = 0;
				int HOUSE_LEFT = 3;
				int settlementPosition = (mouseMotionArtifacts.getMouseMotionSettlement().getHorizontalCardinal()==catan::horizontalCR? HOUSE_RIGHT: HOUSE_LEFT);
				float playerRed = 0.25f;
				float playerGreen = 0.25f;
				float playerBlue = 0.25f;
				glColor3f(playerRed, playerGreen, playerBlue);
				float centerX = (hexagonX[settlementPosition]+xShift)*multiplier;
				float centerY = (hexagonY[settlementPosition]+yShift)*multiplier;
				if (!mouseMotionArtifacts.isMouseMotionSettlementUpgraded())
				{
					drawSettlement(playerRed, playerGreen, playerBlue, centerX, centerY, multiplier);
				}
				else
				{
					drawCity(playerRed, playerGreen, playerBlue, centerX, centerY, multiplier);
				}
			}
		}
	}
	else if (mouseMotionArtifacts.hasMouseMotionRoad())
	{
		CoordinateX coordinateX(static_cast<CoordinateX::Enum_CoordinateX>(x));
		CoordinateY coordinateY(static_cast<CoordinateY::Enum_CoordinateY>(y));
		VerticalCardinal verticalCardinal = mouseMotionArtifacts.getMouseMotionRoad().getVerticalCardinal();
		if (PathCoordinate::canInit(coordinateX, coordinateY, verticalCardinal))
		{
			PathCoordinate currentPathCoordinate(coordinateX, coordinateY, verticalCardinal);
			if (currentPathCoordinate == mouseMotionArtifacts.getMouseMotionRoad())
			{
				int PATH_TR = 0;
				int PATH_TL = 2;
				int PATH_BC = 4;
				int pathPosition;
				if(mouseMotionArtifacts.getMouseMotionRoad().getVerticalCardinal()==catan::verticalTR)
					pathPosition = PATH_TR;
				else if(mouseMotionArtifacts.getMouseMotionRoad().getVerticalCardinal()==catan::verticalTL)
					pathPosition = PATH_TL;
				else if(mouseMotionArtifacts.getMouseMotionRoad().getVerticalCardinal()==catan::verticalBC)
					pathPosition = PATH_BC;
		
				float playerRed = 0.25f;
				float playerGreen = 0.25f;
				float playerBlue = 0.25f;
				glColor3f(playerRed, playerGreen, playerBlue);
				float centerX = ((hexagonX[pathPosition]+hexagonX[(pathPosition+1)%6])/2+xShift)*multiplier;
				float centerY = ((hexagonY[pathPosition]+hexagonY[(pathPosition+1)%6])/2+yShift)*multiplier;
				drawRoad(playerRed, playerGreen, playerBlue, centerX, centerY, pathPosition, multiplier);
			}
		}
	}
	
	if (numberTexture != 0)
	{
        glColor3f(1.0f, 1.0f, 1.0f);
		glBindTexture(GL_TEXTURE_2D, numberTexture);
	    glBegin(GL_POLYGON);
	    	int circleSteps = 12;
	    	for (int k=0; k<circleSteps; ++k)
	    	{
	    		float theta = (float)k/circleSteps*2*M_PI;
	    		float xPart = cos(theta)/2;
	    		float yPart = sin(theta)/2;
				glTexCoord2f(xPart+0.5f, yPart+0.5f);
		        glVertex3f((xPart*0.3f+xShift)*multiplier, (yPart*0.3f+yShift)*multiplier, (0.05f)*multiplier);
	    	}
	    glEnd();
		glBindTexture(GL_TEXTURE_2D, 0);
	}
	glColor3f(1.0f, 1.0f, 1.0f);
}

}
